<script setup lang="ts">
import useRouteCache from '@/stores/modules/routeCache'
import { clearToken, setToken } from '@/utils/auth'
import {getUrlParam} from '@/utils/common'

const keepAliveRouteNames = computed(() => {
  return useRouteCache().routeCaches as string[]
})

const mode = computed(() => {
  return isDark.value ? 'dark' : 'light'
})

const href = location.href
const token = getUrlParam(href, 'token')
console.log('href：',location.href)

setToken(token)

</script>

<template>
  <van-config-provider :theme="mode">
    <router-view v-slot="{ Component }">
      <section class="app-wrapper">
        <keep-alive :include="keepAliveRouteNames">
          <component :is="Component" />
        </keep-alive>
      </section>
    </router-view>
  </van-config-provider>
</template>

<style scoped>
.app-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}
</style>
